home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / kcl / kcl.lha / c / fasload.c < prev    next >
C/C++ Source or Header  |  1987-06-04  |  2KB  |  107 lines

  1. /*
  2. (C) Copyright Taiichi Yuasa and Masami Hagiya, 1984.  All rights reserved.
  3. */
  4.  
  5. /*
  6.     fasload.c
  7.     DG-SPECIFIC
  8. */
  9.  
  10. #include "include.h"
  11.  
  12. int
  13. fasload(filename)
  14. object filename;
  15. {
  16.     object    x;
  17.     object    data, skip_count;
  18.     object    strm;
  19.     int    len, i, byte_count;
  20.     char    *cp;
  21.     char    filen[256];
  22.     int    ob_start;
  23.     object    *base = vs_base;
  24.     object    *top = vs_top;
  25.  
  26.     if (type_of(filename) != t_string)
  27.         FEwrong_type_argument(Sstring, filename);
  28.  
  29.     cp = filename->st.st_self;
  30.     len = filename->st.st_fillp;
  31.  
  32.     for (i=0; i < len; i++) filen[i] = cp[i];
  33.     filen[i] = '\0';
  34.  
  35. #ifdef AOSVS
  36.     strm = open_stream(filename, smm_input, Cnil, Kerror);
  37.     vs_push(strm);
  38.  
  39.     preserving_whitespace_flag = FALSE;
  40.     detect_eos_flag = FALSE;
  41.     skip_count = standard_read_object_non_recursive(strm);
  42.     vs_push(skip_count);
  43.  
  44.     data = read_fasl_vector(strm);
  45.     vs_push(data);
  46.     close_stream(strm, TRUE);
  47.  
  48.     if (type_of(skip_count) != t_fixnum)
  49.         FEerror("too large fasl file", 0);
  50.  
  51.     byte_count = fasl_loader(filen, fix(skip_count), data);
  52. #endif
  53. #ifdef DGUX
  54.     data = read_fasl_data(filen);
  55.     vs_push(data);
  56.  
  57.     byte_count = fasl_loader(filen, 0, data);
  58. #endif
  59.     vs_top = top;
  60.     vs_base = base;
  61.     return(byte_count);
  62. }
  63.  
  64. siLobload()
  65. {
  66.     object    filename;
  67.     int    byte_count;
  68.     int    len, i;
  69.     char    *cp;
  70.     char    filen[256];
  71.     object    *base = vs_base;
  72.     object    *top = vs_top;
  73.  
  74.     check_arg(1);
  75.     check_type_or_pathname_string_symbol_stream(&vs_base[0]);
  76.  
  77.     filename = coerce_to_namestring(vs_base[0]);
  78.  
  79.     cp = filename->st.st_self;
  80.     len = filename->st.st_fillp;
  81.  
  82.     for (i=0; i < len; i++) filen[i] = cp[i];
  83.     filen[i] = '\0';
  84.  
  85.     byte_count = fasl_loader(filen, 0, Cnil);
  86.  
  87.     vs_base = base;
  88.     vs_top = top;
  89.  
  90.     if (byte_count < 0) {
  91.         vs_top = vs_base;
  92.         vs_push(Cnil);
  93.     } else {
  94.         vs_top = vs_base;
  95.         vs_push(make_fixnum(byte_count));
  96.     }
  97. }
  98.  
  99. #ifdef AOSVS
  100. init_fasload()
  101. {
  102.     init_fasl();
  103.     make_si_function("OBLOAD", siLobload);
  104. }
  105. #endif
  106.  
  107.